// Connection view implementation
use iced::{Element, widget::{column, row, text_input, button, text}};

/// Connection view component
pub fn connection_view<'a, Message>(
    connection_string: &'a str,
    is_connected: bool,
    on_connection_change: impl Fn(String) -> Message + 'a,
    on_connect: Message,
    on_disconnect: Message,
) -> Element<'a, Message>
where
    Message: Clone + 'a,
{
    let connection_input = text_input("Database connection string...", connection_string)
        .on_input(on_connection_change);
    
    let connect_button = if is_connected {
        button(text("Disconnect")).on_press(on_disconnect)
    } else {
        button(text("Connect")).on_press(on_connect)
    };
    
    let status_text = if is_connected {
        text("Connected")
    } else {
        text("Disconnected")
    };
    
    column![
        row![connection_input, connect_button].spacing(10),
        status_text
    ]
    .spacing(10)
    .into()
}
